<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;
use yii\helpers\ArrayHelper;

$this->title = 'create';
?>
<style>
	.limit_choose .limit_uname label{font-size:16px;}
	.limit_choose .limit_uname span{margin-left:30px;}
	.limit_choose .check_limit>label{font-size:16px;}
	.limit_choose .limit_role label{font-size:16px;}
	.limit_choose .check_limit .checkbox{width:50%;float:left;margin-top:10px;font-size:15px;}
	.limit_choose .box-footer{text-align:center;}
	.limit_choose .box-footer button{width:200px;}
	.font-info{margin-left:450px;}
	.btn-info{float:right;}
	#authbox{overflow:hidden;}
	#authbox .checkbox{float:left;width:50%;margin-top:10px;}
</style>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<div class="box-header"><h2 class="box-title"><?php if ($model->id){?>修改流程<?php } else {?>新增流程<?php }?></h2></div>
			<div class="box-body add_department">
				<?php $form = ActiveForm::begin(['action' => ['process/create', 'id' => $model->id], 'method' => 'post']);?>
					<div class="box-body">
						<div class="form-group process">
							<label>选择流程</label><input class="btn btn-info add_p" value="新建流程" readonly />
							<select name="pcode" class="form-control">
								<?php if ($process) { ?>
									<option value="">选择流程</option>
									<?php foreach($process as $val) :?>
										<option value="<?= $val['pcode']?>"><?= $val['name']?></option>
									<?php endforeach;?>
								<?php } ?>
							<?=Html::error($model, 'pcode', ['style' => 'color:red'])?>	
							</select>
						</div>
						<div class="form-group">
							<label>转接部门</label>
							<?=Html::dropDownList('tran_depart', $model->tran_depart, ArrayHelper::map($de_arr, 'id', 'name'), ['class'=>'form-control']);?>
							<?=Html::error($model, 'tran_depart', ['style' => 'color:red'])?>
						</div>
						<div class="form-group">
							<label>承接部门</label>
							<?=Html::dropDownList('undertake_depart', $model->undertake_depart, ArrayHelper::map($de_arr, 'id', 'name'), ['class'=>'form-control']);?>
							<?=Html::error($model, 'undertake_depart', ['style' => 'color:red'])?>
						</div>
						<div class="form-group check_limit">
							<label>可控制字段</label>
							<div style="overflow:hidden;" id="authbox">	
				           		<div class="checkbox"><label><input name="control[]" type="checkbox"  value="purchase_time" />购买日期</label></div>
					           	<div class="checkbox"><label><input name="control[]" type="checkbox"  value="check_address" />检测地址</label></div>
					           	<div class="checkbox"><label><input name="control[]" type="checkbox"  value="send_address" />寄送地址</label></div>
					           	<div class="checkbox"><label><input name="control[]" type="checkbox"  value="check_time" />检测时间</label></div>
					           	<div class="checkbox"><label><input name="control[]" type="checkbox"  value="purchase_user" />产品缴费人</label></div>
					           	<div class="checkbox"><label><input name="control[]" type="checkbox"  value="relation" />缴费人与使用人关系</label></div>
					           	<div class="checkbox"><label><input name="control[]" type="checkbox"  value="report_send" />报告寄出时间</label></div>
					           	<div class="checkbox"><label><input name="control[]" type="checkbox"  value="report_back" />报告返回时间</label></div>
					           	<div class="checkbox"><label><input name="control[]" type="checkbox"  value="send_code" />样本寄出单号</label></div>
					           	<div class="checkbox"><label><input name="control[]" type="checkbox"  value="send_time" />样本寄出时间</label></div>
					           	<div class="checkbox"><label><input name="control[]" type="checkbox"  value="delivery_code" />快递单号</label></div>
					           	<div class="checkbox"><label><input name="control[]" type="checkbox"  value="sign_time" />签收时间</label></div>
				            </div>
						</div>
					</div>
					<div class="box-footer">
						<button type="submit" class="btn btn-primary">确定</button>
					</div>
				<?php ActiveForm::end();?>
			</div>
		</div>
	</div>
</section>

<script type="text/javascript" src="js/jquery.js"></script> 
<script>
	/*新建流程切换*/
	$(".process").on('click', '.add_p', function(){
		var html = "<label>新建流程</label>"+"<input class='btn btn-info choise_p' value='选择流程' readonly />"+
					"<input type='text' class='form-control' name='new_process' />";
		$(".process").html(html);
	});
	/*选择流程切换*/
	$(".process").on('click', '.choise_p', function(){
		var html = 	"<label>选择流程</label>"+"<input class='btn btn-info add_p' value='新建流程' readonly />"+
					"<select name='pcode' class='form-control'>"+
						"<?php if ($process) { ?>"+
							"<option value=''>选择流程</option>"+
							"<?php foreach($process as $val) :?>"+
								"<option value='<?= $val['pcode']?>'>"+"<?= $val['name']?></option>"+
							"<?php endforeach;?>"+
						"<?php } ?>"+
					"</select>";
		$(".process").html(html);				
	});
</script>